<template>
  <div>
    <el-form :model="form" size="small" inline>
      <el-form-item label="代码">
        <el-input v-model="form.code" />
      </el-form-item>
      <el-form-item label="时间">
        <el-date-picker v-model="form.startDate" value-format="yyyy-MM-dd" placeholder="" />
        <el-date-picker v-model="form.endDate" value-format="yyyy-MM-dd" placeholder="" />
      </el-form-item>
      <el-form-item label="">
        <el-button type="primary" size="small" @click="getTrendPeriod">查询</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" height="450px" :data="list" cell-class-name="tableColumn" size="small" border>
      <el-table-column label="code" prop="code" align="center" />
      <el-table-column label="名称" prop="name" align="center" />
      <el-table-column label="行业" prop="industry" align="center" />
      <el-table-column label="入场日期" prop="startDate" align="center" />
      <el-table-column label="离场日期" prop="endDate" align="center" />
      <el-table-column label="入场价格" prop="startPrice" align="center" />
      <el-table-column label="离场价格" prop="endPrice" align="center" />
      <el-table-column label="收益率" align="center" prop="yield" />
      <el-table-column label="" align="center">
        <template slot-scope="{row}">
          <el-button type="text" @click="showDeatil(row)">详情</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-dialog title="详情" :visible.sync="showDeatilVisible" width="90%">
      <EveryPrice v-if="showDeatilVisible" :row="activeRow" />
    </el-dialog>
  </div>
</template>

<script>
import { getTrendPeriod } from '@/api/base'
import EveryPrice from './everyPrice.vue'
export default {
  components: { EveryPrice },
  data() {
    return {
      loading: false,
      form: {},
      list: [],
      activeRow: {},
      showDeatilVisible: false
    }
  },
  mounted() {
    this.getTrendPeriod()
  },
  methods: {
    async getTrendPeriod() {
      this.loading = true
      const { list } = await getTrendPeriod(this.form)
      this.list = list
      this.loading = false
    },
    showDeatil(row) {
      this.activeRow = { ...row }
      this.showDeatilVisible = true
    }
  }
}
</script>

<style>

</style>
